﻿using System;
using SharpSqlAnalyzer.nodes;

namespace SharpSqlAnalyzer.stmt.mysql
{
	// Token: 0x02000152 RID: 338
	public class TMySQLCreateProcedure : TStoredProcedureSqlStatement
	{
		// Token: 0x06000B59 RID: 2905 RVA: 0x00305EFD File Offset: 0x003040FD
		public TMySQLCreateProcedure(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstmysqlcreateprocedure;
		}

		// Token: 0x06000B5A RID: 2906 RVA: 0x00305F11 File Offset: 0x00304111
		internal override void buildsql()
		{
		}

		// Token: 0x06000B5B RID: 2907 RVA: 0x00305F13 File Offset: 0x00304113
		internal override void clear()
		{
		}

		// Token: 0x06000B5C RID: 2908 RVA: 0x00305F15 File Offset: 0x00304115
		internal override string getasprettytext()
		{
			return "";
		}

		// Token: 0x06000B5D RID: 2909 RVA: 0x00305F1C File Offset: 0x0030411C
		internal virtual void iterate(TVisitorAbs pvisitor)
		{
		}

		// Token: 0x17000213 RID: 531
		// (get) Token: 0x06000B5E RID: 2910 RVA: 0x00305F1E File Offset: 0x0030411E
		public override TObjectName StoredProcedureName
		{
			get
			{
				return this.procedureName;
			}
		}

		// Token: 0x17000214 RID: 532
		// (get) Token: 0x06000B5F RID: 2911 RVA: 0x00305F26 File Offset: 0x00304126
		// (set) Token: 0x06000B60 RID: 2912 RVA: 0x00305F2E File Offset: 0x0030412E
		public virtual TObjectName ProcedureName
		{
			get
			{
				return this.procedureName;
			}
			set
			{
				this.procedureName = value;
			}
		}

		// Token: 0x06000B61 RID: 2913 RVA: 0x00305F38 File Offset: 0x00304138
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			TCreateProcedureSqlNode tcreateProcedureSqlNode = (TCreateProcedureSqlNode)this.rootNode;
			base.doParseStatement(psql);
			this.procedureName = tcreateProcedureSqlNode.ProcedureName;
			base.DatabaseObjects.Add(this.procedureName);
			this.ParameterDeclarations = tcreateProcedureSqlNode.Parameters;
			if (this.ParameterDeclarations != null)
			{
				for (int i = 0; i < this.ParameterDeclarations.size(); i++)
				{
					this.TopStatement.SymbolTable.Push(new TSymbolTableItem(9, this, this.ParameterDeclarations.getParameterDeclarationItem(i)));
				}
			}
			if (tcreateProcedureSqlNode.Stmt != null)
			{
				tcreateProcedureSqlNode.Stmt.doParse(this, ESqlClause.unknown);
				this.BodyStatements.add(tcreateProcedureSqlNode.Stmt.Stmt);
			}
			else if (tcreateProcedureSqlNode.Blcok != null)
			{
				tcreateProcedureSqlNode.Blcok.Stmts.doParse(this, ESqlClause.unknown);
				for (int j = 0; j < tcreateProcedureSqlNode.Blcok.Stmts.size(); j++)
				{
					this.BodyStatements.add(tcreateProcedureSqlNode.Blcok.Stmts.getStatementSqlNode(j).Stmt);
				}
			}
			if (this.ParameterDeclarations != null)
			{
				for (int k = 0; k < this.ParameterDeclarations.size(); k++)
				{
					this.TopStatement.SymbolTable.Pop();
				}
			}
			return 0;
		}

		// Token: 0x06000B62 RID: 2914 RVA: 0x00306081 File Offset: 0x00304281
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000B63 RID: 2915 RVA: 0x00306091 File Offset: 0x00304291
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			if (this.ParameterDeclarations != null)
			{
				this.ParameterDeclarations.acceptChildren(v);
			}
			this.BodyStatements.acceptChildren(v);
			v.postVisit(this);
		}

		// Token: 0x040012AF RID: 4783
		private TObjectName procedureName;
	}
}
